<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>SoapServer constructor</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="soapserver.addsoapheader.html">« SoapServer::addSoapHeader</a></li>
      <li style="float: right;"><a href="soapserver.fault.html">SoapServer::fault »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.soapserver.html">SoapServer</a></li>
    <li>SoapServer constructor</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="soapserver.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SoapServer::__construct</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SoapServer::__construct</span> &mdash; <span class="dc-title">SoapServer constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-soapserver.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SoapServer::__construct</strong></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$wsdl</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code><span class="initializer"> = []</span></span>)</div>

  <p class="para rdfs-comment">
   This constructor allows the creation of <span class="classname"><a href="class.soapserver.html" class="classname">SoapServer</a></span>
   objects in WSDL or non-WSDL mode.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-soapserver.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">wsdl</code></dt>

     <dd>

      <p class="para">
       To use the SoapServer in WSDL mode, pass the URI of a WSDL file.
       Otherwise, pass <strong><code>null</code></strong> and set the <code class="literal">uri</code> option to the
       target namespace for the server.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       Allow setting a default SOAP version (<code class="literal">soap_version</code>),
       internal character encoding (<code class="literal">encoding</code>),
       and actor URI (<code class="literal">actor</code>).
      </p>
      <p class="para">
       The <code class="literal">classmap</code> option can be used to map some WSDL
       types to PHP classes. This option must be an array with WSDL types
       as keys and names of PHP classes as values.
      </p>
      <p class="para">
       The <code class="literal">typemap</code> option is an array of type mappings.
       Type mapping is an array with keys <code class="literal">type_name</code>,
       <code class="literal">type_ns</code> (namespace URI), <code class="literal">from_xml</code>
       (callback accepting one string parameter) and <code class="literal">to_xml</code>
       (callback accepting one object parameter).
      </p>
      <p class="para">
       The <code class="literal">cache_wsdl</code> option is one of
       <strong><code>WSDL_CACHE_NONE</code></strong>,
       <strong><code>WSDL_CACHE_DISK</code></strong>,
       <strong><code>WSDL_CACHE_MEMORY</code></strong> or
       <strong><code>WSDL_CACHE_BOTH</code></strong>.
      </p>
      <p class="para">
       There is also a <code class="literal">features</code> option which can be set to
       <strong><code>SOAP_WAIT_ONE_WAY_CALLS</code></strong>,
       <strong><code>SOAP_SINGLE_ELEMENT_ARRAYS</code></strong>,
       <strong><code>SOAP_USE_XSI_ARRAY_TYPE</code></strong>.
      </p>
      <p class="para">
       The <code class="literal">send_errors</code> option can be set to <strong><code>false</code></strong> to sent a
       generic error message (&quot;Internal error&quot;) instead of the specific error
       message sent otherwise.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-soapserver.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5342">
    <p><strong>示例 #1 <span class="function"><strong>SoapServer::__construct()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'soap_version'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOAP_1_2</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'actor'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://example.org/ts-tests/C"</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"some.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'encoding'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'ISO-8859-1'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'uri'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"http://test-uri/"</span><span style="color: #007700">));<br /><br />class&nbsp;</span><span style="color: #0000BB">MyBook&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$title</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$author</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$server&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SoapServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"books.wsdl"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'classmap'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(</span><span style="color: #DD0000">'book'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"MyBook"</span><span style="color: #007700">)));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-soapserver.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="soapclient.construct.html" class="methodname" rel="rdfs-seeAlso">SoapClient::__construct()</a> - SoapClient constructor</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>